// api/payment.js
import axios from 'axios';

const BASE_URL = 'https://2b15fa7cb754.ngrok-free.app/product/api/payment';

// 获取支付二维码
export const getPaymentQRCode = async (params) => {
  try {
    const response = await axios.get(`${BASE_URL}/qr-code`, {
      params: {
        ordersId: params.ordersId,
        totalAmount: params.totalAmount,
        subject: params.subject,
      },
      headers: {
        'ngrok-skip-browser-warning': 'true'
      }
    });
    return response;
  } catch (error) {
    console.error('获取支付二维码失败:', error);
    throw error;
  }
};

// 查询支付状态
export const checkPaymentStatus = async (orderId) => {
  try {
    const response = await axios.get(`${BASE_URL}/status`, {
      params: { orderId },
      headers: {
        'ngrok-skip-browser-warning': 'true'
      }
    });
    return response;
  } catch (error) {
    console.error('查询支付状态失败:', error);
    throw error;
  }
};